home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2640 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.1 KB  |  28 lines

  1. Newsgroups: comp.lang.c++
  2. Path: novice.uwaterloo.ca!mkalisia
  3. From: mkalisia@novice.uwaterloo.ca (Maciej Kalisiak)
  4. Subject: casting virtual base classpointer to derived
  5. Sender: news@novice.uwaterloo.ca (Mr. News)
  6. Message-ID: <DLE98M.nEI@novice.uwaterloo.ca>
  7. Date: Thu, 18 Jan 1996 20:36:22 GMT
  8. Nntp-Posting-Host: novice.uwaterloo.ca
  9. Organization: University of Waterloo
  10.  
  11. I ran into a "limitation" of C++ that I wasn't aware off, and I was
  12. hoping someone out there can tell me how to get around this
  13. limitation:
  14.  
  15. I have a base class Base. I derive a number of other classes from Base
  16. using "virtual public". I have an array/list of Base*, which holds
  17. pointers to a whole bunch of object of type Base, or any of the derived
  18. ones. I take one of these pointers (Base*) and I know that it was
  19. really pointing to a derived class. I try to cast to this derived class
  20. but I can't (supposedly all compilers are supposed to issue an error in
  21. such a case).
  22.  
  23. Any ideas of how to keep such a list of derived type objets using
  24. Base*'s, or how to get around this ???
  25.  
  26. I am using Watcom v10.0
  27.  
  28.